{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2d23221c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "\n",
    "headers = {\n",
    "    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8bed77cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url_em = \"https://quote.eastmoney.com/center/gridlist.html#hs_a_board\"\n",
    "resp = requests.get(url_em)\n",
    "resp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "17cbdd49",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<!DOCTYPE html><html><head><meta charSet=\"utf-8\"/><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/><meta name=\"referrer\" content=\"always\"/><meta name=\"sinfo\" data-bz=\"STime: 2025-08-05 21:41:39 SNum: 194\"/><title>行情中心：国内快捷全面的股票、基金、期货、美股、港股、外汇、黄金、债券行情系统_东方财富网</title><meta name=\"keywords\" content=\"沪深股市, 沪深A股, 沪深指数, 创业板行情, 期指行情, 板块, 排行, 香港股市, 美股行情, 港股行情, 全球指数, 基金净值, 基金估值, ETF, LOF, 基金行情, 期货行情, 外汇, 人民币中间价, 外汇牌价, 汇率, 黄金, 黄金期货, 黄金现货, 纸黄金, 国际贵金属期货, 债券指数, 国债, 企债, 转债, 银行间市场, 上证回购, 深证回购 \"/><meta name=\"description\" content=\"东方财富网行情中心提供权威、全面、专业、及时的行情数据，将沪深股市实时行情、港股行情、全球股市走势、权证、基金行情、期货行情、外汇行情、债券行情、黄金行情进行优化整合、为投资者搭建了一个可以纵览全球行情的重要平台，为您的投资提供重要依据。\"/><base target=\"_blank\"/><link rel=\"stylesheet\" href=\"./static/build/index.css\"/></head><body><div class=\"main\"><div id=\"qq_top_tg\"></div><div class=\"toplinks blink\"><ul><li><a href=\"http://finance.eastmoney.com/\" >财经</a></li><li><a href=\"http://finance.eastmoney.com/yaowen.html\" >焦点</a></li><li><a href=\"http://stock.eastmoney.com/\" >股票</a></li><li><span class=\"red\"><a href=\"http://stock.eastmoney.com/newstock.html\" >新股</a></span></li><li><a href=\"http://stock.eastmoney.com/gzqh.html\" >期指</a></li><li><a href=\"http://option.eastmoney.com/\" >期权</a></li><li><span class=\"red\"><a href=\"http://quote.eastmoney.com/flash/sz300059.html\" >行情</a></span></li><li><a href=\"http://data.eastmoney.com/\" >数据</a></li><li><a href=\"http://stock.eastmoney.com/global.html\" >全球</a></li><li><a href=\"http://stock.eastmoney.com/america.html\" >美股</a></li><li><a href=\"http://hk.eastmoney.com/\" >港股</a></li><li><a href=\"http://futures.eastmoney.com/\" >期货</a></li><li><a href=\"http://forex.eastmoney.com/\" >外汇</a></li><li><a href=\"http://bank.eastmoney.com/\" >银行</a></li><li><a href=\"http://www.1234567.com.cn/\" >基金</a></li><li><a href=\"http://money.eastmoney.com/\" >理财</a></li><li><a href=\"http://bond.eastmoney.com/\" >债券</a></li><li><a href=\" https://roadshow.eastmoney.com/\" >直播</a></li><li><span class=\"red\"><a href=\"http://guba.eastmoney.com/\" >股吧</a></span></li><li><a href=\"http://guba.eastmoney.com/jj.html\" >基金吧</a></li><li><a href=\"http://blog.eastmoney.com/\" >博客</a></li><li><span class=\"red\"><a href=\"http://caifuhao.eastmoney.com/\" >财富号</a></span></li><li><a href=\"http://so.eastmoney.com/\" >搜索</a></li></ul></div><div class=\"toptitle scf\"><div class=\"logo\"><a href=\"http://www.eastmoney.com\"><img src=\"./static/images/logo.png\" class=\"logoimg\" title=\"东方财富网\"/></a><a href=\"./\"><span class=\"title\">行情中心</span></a></div><div class=\"tglinks\"><ul><li><a href=\"//kuaixun.eastmoney.com/\"><span class=\"icon_globe\"></span>全球财经快讯</a></li><li><a href=\"//data.eastmoney.com/\"><span class=\"icon_chart\"></span>数据中心</a></li><li><a href=\"//wap.eastmoney.com/\"><span class=\"icon_mobile\"></span>手机站</a></li><li><a href=\"//acttg.eastmoney.com/pub/pctg_hskh_act_gfcgrj_01_01_01_0\"><span class=\"icon_mobile2\"></span>客户端</a></li><li><a href=\"https://choice.eastmoney.com?adid=web_choice_hqpd_website_01_01_01_0\"><span class=\"icon_choice\"></span>Choice数据</a></li><li><a href=\"https://ai.eastmoney.com/miaoxiang/?adid=web_mx_hqzx_website_01_01_01_0\"><span class=\"icon_mx\"></span>妙想大模型</a></li><li><a href=\"//fundact.eastmoney.com/app/?spm=100003.mjj\"><span class=\"icon_download\"></span>手机买基金 国内外市场轻松投</a></li></ul></div></div><div class=\"topsearch scf\"><ul class=\"topsearch_l blink\"><li><a title=\"行情数据\" target=\"_blank\" href=\"./\">行情数据</a></li><li><a target=\"_blank\" href=\"https://jywg.18.cn/Trade/Buy\"><span class=\"icon_zq\"></span>证券交易</a></li><li><a target=\"_blank\" href=\"http://www.1234567.com.cn/\"><span class=\"icon_jj\"></span>基金理财</a></li><li><a target=\"_blank\" href=\"http://group.eastmoney.com/\"><span class=\"icon_zh\"></span>投资组合</a></li><li><a target=\"_blank\" href=\"http://guba.eastmoney.com/\"><span class=\"icon_gb\"></span>股吧互动</a></li></ul><div class=\"topsearch_s\"><form id=\"suggest_wrapper\"><input type=\"text\" name=\"search-suggest\" class=\"topnav2seinp\" id=\"search_box\"/><input type=\"submit\" id=\"search_btn\" class=\"topnav2sebtn\" value=\"搜索\"/></form></div></div><div class=\"topquote\"><div class=\"topquote_i topquote_i_b\"><div class=\"topquote_l\"><a href=\"https://quote.eastmoney.com/\"><span class=\"icon_quote\"></span>行情中心</a></div><div class=\"topquote_r\"><div class=\"topquote_tglinks\"><ul><li><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_01_0\" >指数</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_02_0\" >期指</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_03_0\" >期权</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_04_0\" >个股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_05_0\" >板块</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_06_0\" >行业</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_07_0\" >概念</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_08_0\" >排行</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_09_0\" >新股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_10_0\" >北交所</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_11_0\" >创业板</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_12_0\" >科创板</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_14_0\" >基金</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_13_0\" >港股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_15_0\" >沪深港</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_16_0\" >美股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_17_0\" >期货</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_18_0\" >黄金</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_19_0\" >外汇</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_20_0\" >自选股</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_21_0\" >自选基金</a><a href=\"https://xuangu.eastmoney.com/\" >条件选股</a><span class=\"red\"><a href=\"https://quote.eastmoney.com/stockhotmap/\" >大盘星图</a></span></li></ul></div></div></div><div class=\"topquote_i\"><div class=\"topquote_l blink\"><a href=\"qqzs.html\"><span class=\"icon_globe2\"></span>全球股市</a></div><div class=\"topquote_r\"><div class=\"globalstocks\" id=\"globalstocks\"></div><div class=\"topquote_rtg\"><a target=\"_blank\" href=\"http://acttg.eastmoney.com/pub/web_pc_dcsy_qqgs_01_01_01_1\" class=\"cft-dl redlink\"><span class=\"icon_em\"></span>东方财富官方炒股软件</a><a target=\"_blank\" href=\"http://acttg.eastmoney.com/pub/web_pc_dcsy_qqgs_01_01_02_1\" class=\"qdhq-dl redlink\"><span class=\"icon_flash\"></span>快速行情</a></div></div></div><div class=\"topquote_i\"><div class=\"topquote_l blink\"><a href=\"http://data.eastmoney.com/\"><span class=\"icon_chart2\"></span>数据中心</a></div><div class=\"topquote_r\"><div class=\"topquote_tglinks2\"><ul><li><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_01_0\" >资金流向</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_02_0\" >主力排名</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_03_0\" >板块资金</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_04_0\" >个股研报</a><span class=\"red\"><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_05_0\" >新股申购</a></span><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_06_0\" >转债申购</a><span class=\"red\"><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_07_0\" >北交所申购</a></span><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_08_0\" >AH股比价</a><a href=\"https://data.eastmoney.com/bbsj/202412/yjbb.html\" >年报大全</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_10_0\" >融资融券</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_11_0\" >龙虎榜</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_12_0\" >限售解禁</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_13_0\" >IPO审核</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_14_0\" >大宗交易</a><span class=\"red\"><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_15_0\" >估值分析</a></span></li></ul></div></div></div><div class=\"topquote_i\"><div class=\"topquote_l blink\"><a href=\"hsgt.html\"><span class=\"icon_change\"></span>沪深港通</a></div><div class=\"topquote_r\"><div class=\"tq_hsgt\" id=\"tq_hsgt\"></div></div></div></div><div class=\"bhistory scf\"><div class=\"bs_l\">最近访问：</div><div id=\"bhistory\"></div><div class=\"bs_toutiao\"><div class=\"t\"><a href=\"//js1.eastmoney.com/tg.aspx?ID=3979\"><span class=\"icon_toutiao\"></span>头条</a>：</div><div class=\"list red\"><a href=\"//js1.eastmoney.com/tg.aspx?ID=3979\">金融支持新型工业化最新部署</a></div></div><div id=\"zhrool\"></div></div><div class=\"mainlc scf\" id=\"mainpage\"></div><div class=\"statement\">郑重声明：本网站所刊载的所有资料及图表仅供参考使用。投资者依据本网站提供的信息、资料及图表进行金融、证券等投资所造成的盈亏与本网站无关。本网站如因系统维护或升级而需暂停服务，或因线路及超出本公司控制范围的硬件故障或其它不可抗力而导致暂停服务，于暂停服务期间造成的一切不便与损失，本网站不负任何责任。</div></div><div class=\"footer page_footer\"><!-- footer-2016 -->\\n<style>\\n    .footer2016 ul {list-style: none;margin: 0;padding: 0;}\\n    .footer2016 a:hover{color:#ff4901 !important;text-decoration: underline !important;}\\n    .footer2016 .icon, .footer2016 .navlist li a {display: inline-block;}\\n    .footer2016 .icon {background-image: url(//g1.dfcfw.com/g4/202005/20200513165332.png);background-repeat: no-repeat;}\\n    .footer2016 {margin: 0 auto;clear: both;width: 1200px;line-height: 1.1;_line-height: 1.2;font-family: simsun;font-size: 12px;border-top: 2px solid #2F5895;}\\n    .footer2016 .footertg {background-color: #F3F3F3;float: left;width: 100%;padding: 12px 0 0;height: 140px;}\\n    .footer2016 .footertg a:link, .footer2016 .footertg a:visited {color: #676767;text-decoration: none;}\\n    .footer2016 .qr {float: left;width: 80px;height: 140px;line-height: 150%;padding: 0 20px 0 8px;}\\n    .footer2016 .qr .t {font-weight: 700;font-size: 14px;padding-bottom: 10px;}\\n    .footer2016 .icon_qrem80, .footer2016 .icon_qrjj80 {background-image: url(//g1.dfcfw.com/g2/201607/20160728133707.png);width: 80px;height: 80px;}\\n    .footer2016 .icon_qrem80 {background-position: 0 -330px;}\\n    .footer2016 .icon_emwxqr, .footer2016 .icon_jjwxqr {background-image: url(//g1.dfcfw.com/g2/201607/20160728133707.png);width: 86px;height: 106px;}\\n    .footer2016 .icon_emwxqr {background-position: -90px 0;}\\n    .footer2016 .ftglist ul li.qrli {position: relative;}\\n    .footer2016 .ftglist ul li.qrli:hover .icon_qr, .footer2016 .scl-news .name a {display: block;}\\n    .footer2016 .icon_emwxqr, .footer2016 .icon_jjwxqr {display: none;position: absolute;left: 0;top: 24px;}\\n    .footer2016 .ftglist {float: left;height: 140px;padding: 0 20px;}\\n    .footer2016 .ftglistt {font-size: 14px;font-weight: 700;line-height: 130%;padding-bottom: 6px;text-align: left;}\\n    .footer2016 .ftglist ul li {padding: 5px 0;color: #676767;text-align: left;}\\n    .footer2016 .icon_wb {background-position: -24px 0;width: 14px;height: 12px;}\\n    .footer2016 .icon_wx {background-position: 0 0;width: 14px;height: 11px;}\\n    .footer2016 .icon_note {background-position: -47px 0;width: 13px;height: 11px;}\\n    .footer2016 .ftglist .icon {vertical-align: -1px;margin-right: 2px;}\\n    .footer2016 .footertg a:link, .footer2016 .footertg a:visited {color: #676767;text-decoration: none;}\\n    .footer2016 .qrl {border-left: 1px solid #ddd;margin-left: 20px;padding-left: 40px;}\\n    .footer2016 .icon_qrjj80 {background-position: -90px -330px;}\\n    .footer2016 .footercr {clear: both;text-align: center;line-height: 26px;font-size: 12px;width:1200px;margin: 0 auto;height:26px;overflow:hidden;}\\n    .footer2016 .icon_icp {background-position: -24px -21px;width: 15px;height: 17px;}\\n    .footer2016 .footercr .icon {vertical-align: -3px;margin-right: 2px;}\\n    .footer2016 .icon_pol {background-position: 0 -22px;width: 18px;height: 20px;}\\n    .footer2016 .footerlinks {background-color: #2F5895;height: 30px;text-align: center;line-height: 30px;}\\n    .footer2016 .footerlinks a:link, .footer2016 .footerlinks a:visited, .footer2016 .footerlinks a:hover {color: #fff !important;text-decoration: none;margin: 0 14px;}\\n    .footer2016 .footerbz {text-align: center;padding: 12px 0;}\\n    .footer2016 .footerbz a {margin: 0 4px;}\\n    .footer2016 .footer-police {background-position: 0 -112px;width: 110px;height: 40px;}\\n    .footer2016 .footer-zx110 {background-position: -120px -113px;width: 110px;height: 40px;}\\n    .footer2016 .footer-shjubao {background-position: 0 -172px;width: 110px;height: 40px;}\\n    .footer2016 .footer-cxzx {background-position: -120px -174px;width: 40px;height: 40px;}\\n    .footer2016 .footer-shgs {background-position: -180px -174px;width: 47px;height: 40px;}\\n    .footer2016 .footer-12377 {background-position: 0 -54px;width: 186px;height: 40px;}\\n    .footer2016 .footer-yhjb {background-position: 0 -229px;width: 123px;height: 40px;}\\n    .footer2016 .footer-qrlast {width: 90px;}\\n    .footer2016 .footer-icon-qihuoqr { background: url(https://g1.dfcfw.com/g4/202303/20230324150231.png);width: 80px;height: 80px;display: inline-block;background-repeat: no-repeat;vertical-align: -5px;}\\n    .footer2016 .footer-lastqihuo { padding-right: 0px;}\\n</style>\\n\\n<div class=\"footer2016\">\\n    <div class=\"footertg\">\\n        <div class=\"qr\">\\n            <div class=\"t\"><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_dbtg_wzl_01_01_01_1\" style=\"color:#000\" target=\"_blank\">东方财富</a></div>\\n            <a href=\"http://acttg.eastmoney.com/pub/web_app_dcsy_2wm_01_01_01_0\" target=\"_blank\"><em class=\"icon icon_qrem80\"></em></a><br />扫一扫下载APP\\n        </div>\\n\\n        <div class=\"ftglist\">\\n            <div class=\"ftglistt\">东方财富产品</div>\\n            <ul>\\n                <li><a href=\"https://acttg.eastmoney.com/pub/pctg_hskh_act_dfcfwmfb_01_01_01_0\" target=\"_blank\">东方财富免费版</a></li>\\n                <li><a href=\"https://acttg.eastmoney.com/pub/pctg_hskh_act_dfcfwl2_01_01_01_0\" target=\"_blank\">东方财富Level-2</a></li>\\n                <li><a href=\"https://www.dfcfw.com/CLB/\" target=\"_blank\">东方财富策略版</a></li>\\n                <li><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_bottom_02_02_04_1\" target=\"_blank\">妙想投研助理</a></li>\\n                <li><a href=\"https://choice.eastmoney.com/terminal?adid=web_choice_dcsy_website_02_01_01_0\" target=\"_blank\">Choice金融终端</a></li>\\n            </ul>\\n        </div>\\n        <div class=\"ftglist\">\\n            <div class=\"ftglistt\">证券交易</div>\\n            <ul>\\n                <li><a href=\"https://acttg.eastmoney.com/pub/web_kh_dcsy_dbtkwzl_01_01_01_0\" target=\"_blank\">东方财富证券开户</a></li>\\n                <li><a href=\"https://jywg.18.cn/Trade/Buy\" target=\"_blank\">东方财富在线交易</a></li>\\n\\t\\t\\t\\t<li><a href=\"https://acttg.eastmoney.com/pub/pctg_hskh_act_dfcfzqjy_01_01_01_0\"  target=\"_blank\">东方财富证券交易</a></li>\\n            </ul>\\n        </div>\\n        <div class=\"ftglist\">\\n            <div class=\"ftglistt\">关注东方财富</div>\\n            <ul>\\n                <li><a href=\"http://weibo.com/dfcfw\" target=\"_blank\"><em class=\"icon icon_wb\"></em>东方财富网微博</a></li>\\n                <li class=\"qrli\"><a href=\"javascript:;\" target=\"_self\"><em class=\"icon icon_wx\"></em>东方财富网微信</a><em class=\"icon icon_qr icon_emwxqr\"></em></li>\\n                <li><a href=\"http://corp.eastmoney.com/Lianxi_liuyan.asp\" target=\"_blank\"><em class=\"icon icon_note\"></em>意见与建议</a></li>\\n            </ul>\\n        </div>\\n        <div class=\"qr qrl\">\\n            <div class=\"t\"><a href=\"http://acttg.eastmoney.com/pub/web_ttjjsy_dbtg_wzl_01_01_01_1\" style=\"color:#000\" target=\"_blank\">天天基金</a></div>\\n            <a href=\"http://js1.eastmoney.com/tg.aspx?ID=4672\" target=\"_blank\"><em class=\"icon icon_qrjj80\"></em></a><br />扫一扫下载APP\\n        </div>\\n        <div class=\"ftglist\">\\n            <div class=\"ftglistt\">基金交易</div>\\n            <ul>\\n                <li><a href=\"https://trade6.1234567.com.cn/reg/step1\" target=\"_blank\">基金开户</a></li>\\n                <li><a href=\"https://trade.1234567.com.cn/login\" target=\"_blank\">基金交易</a></li>\\n                <li><a href=\"http://huoqibao.1234567.com.cn/\" target=\"_blank\">活期宝</a></li>\\n                <li><a href=\"http://fund.eastmoney.com/trade/default.html\" target=\"_blank\">基金产品</a></li>\\n                <li><a href=\"http://fund.eastmoney.com/gslc/\" target=\"_blank\">稳健理财</a></li>\\n            </ul>\\n        </div>\\n        <div class=\"ftglist\">\\n            <div class=\"ftglistt\">关注天天基金</div>\\n            <ul>\\n                <li><a href=\"http://weibo.com/ttfund\" target=\"_blank\"><em class=\"icon icon_wb\"></em>天天基金网微博</a></li>\\n                <li class=\"qrli\"><a href=\"javascript:;\" target=\"_self\"><em class=\"icon icon_wx\"></em>天天基金网微信<em class=\"icon icon_qr icon_jjwxqr\"></em></a></li>\\n            </ul>\\n        </div>\\n        <div class=\"qr qrl footer-qrlast\">\\n            <div class=\"t\"><a href=\"https://qs.dfcfw.com/1605\" style=\"color:#000\" target=\"_blank\">东方财富期货</a></div>\\n            <a href=\"http://acttg.eastmoney.com/pub/web_kh_dcsy_dibudfcfqh_01_01_01_1\" target=\"_blank\"><em class=\"footer-icon-qihuoqr\"></em></a><br>扫一扫下载APP\\n        </div>\\n        <div class=\"ftglist footer-lastqihuo\">\\n            <div class=\"ftglistt\">期货交易</div>\\n            <ul>\\n                <li><a href=\"https://qs.dfcfw.com/1606\" target=\"_blank\">期货手机开户</a></li>\\n                <li><a href=\"https://qs.dfcfw.com/1607\" target=\"_blank\">期货电脑开户</a></li>\\n                <li><a href=\"https://qs.dfcfw.com/1608\" target=\"_blank\">期货官方网站</a></li>\\n            </ul>\\n        </div>\\n    </div>\\n        <div class=\"footercr\" style=\"padding-top:8px;\">信息网络传播视听节目许可证：0908328号 经营证券期货业务许可证编号：913101046312860336 违法和不良信息举报:021-61278686 举报邮箱：<a target=\"_self\" href=\"mailto:jubao@eastmoney.com\">jubao@eastmoney.com</a></div>\\n        <div class=\"footercr\" style=\"padding-bottom:8px;\">\\n            <em class=\"icon icon_icp\"></em>沪ICP证:沪B2-20070217 <a target=\"_blank\" rel=\"nofollow\" href=\"https://beian.miit.gov.cn/\" style=\"color: #3F3F3F;text-decoration:none;\">网站备案号:沪ICP备05006054号-11 </a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31010402000120\" target=\"_blank\" style=\"color: #3F3F3F;text-decoration:none;\"><em class=\"icon icon_pol\"></em>沪公网安备 31010402000120号</a> 版权所有:东方财富网 <span class=\"yjyfk\">意见与建议:4000300059/952500</span>\\n        </div>\\n    <div class=\"footerlinks\">\\n\\t\\t\\t<a href=\"http://about.eastmoney.com\" target=\"_blank\" rel=\"nofollow\">关于我们</a>\\n            <a href=\"https://about.eastmoney.com/about/sdindex\" target=\"_blank\" rel=\"nofollow\">可持续发展</a>\\n\\t\\t\\t<a href=\"http://emhd2.eastmoney.com/market\" target=\"_blank\" rel=\"nofollow\">广告服务</a>\\n\\t\\t\\t<a href=\"http://about.eastmoney.com/home/contact\" target=\"_blank\" rel=\"nofollow\">联系我们</a>\\n\\t\\t\\t<a href=\"https://zhaopin.eastmoney.com/\" target=\"_blank\" rel=\"nofollow\">诚聘英才</a>\\n\\t\\t\\t<a href=\"http://about.eastmoney.com/home/legal\" target=\"_blank\" rel=\"nofollow\">法律声明</a>\\n            <a href=\"http://about.eastmoney.com/home/conceal\" target=\"_blank\" rel=\"nofollow\">隐私保护</a>\\n\\t\\t\\t<a href=\"http://about.eastmoney.com/home/parper\" target=\"_blank\" rel=\"nofollow\">征稿启事</a>\\n\\t\\t\\t<a href=\"http://about.eastmoney.com/home/links\" target=\"_blank\" rel=\"nofollow\">友情链接</a>\\n    </div>\\n    <div class=\"footerbz\">\\n        <img src=\"//g1.dfcfw.com/g3/201905/20190531140719.png\" title=\"亲爱的市民朋友，上海警方反诈劝阻电\\n话“962110”系专门针对避免您财产被\\n骗受损而设，请您一旦收到来电，立即\\n接听。\" style=\"vertical-align: bottom;\">\\n        <span class=\"icon footer-police\" title=\"上海网警网络110\" style=\"position: relative; margin: 0 4px;\"></span>\\n        <span class=\"icon footer-zx110\" title=\"网络社会征信网\" style=\"position: relative;margin: 0 4px;\"></span>\\n        <a rel=\"nofollow\" href=\"http://www.shjbzx.cn/\" class=\"icon footer-shjubao\" title=\"上海违法和违规信息举报中心\" target=\"_blank\"></a>\\n        <a rel=\"nofollow\" href=\"http://www.12377.cn\" class=\"icon footer-12377\" title=\"中国互联网违法和不良信息举报中心\" target=\"_blank\"></a>\\n\\t</div>\\n</div>\\n\\n<script>\\n    if(document.all && !window.XMLHttpRequest){\\n        $(\".qrli\").hover(function(){\\n            $(\".icon_qr\",this).show();\\n        },function(){\\n            $(\".icon_qr\",this).hide();\\n        });\\n    }\\n</script></div></body></html><script src=\"./static/libs/oldie.js\"></script><script src=\"./static/libs/libs.min.js\"></script><script src=\"//emcharts.dfcfw.com/suggest/stocksuggest2017.min.js\"></script><script src=\"//emcharts.dftzj.com/ec/3.18.2/emcharts.min.js\"></script><script src=\"./static/libs/miniquotechart2023.js\"></script><script src=\"./static/libs/quotecenter.svgcharts2023.js\"></script><script type=\"text/javascript\">\\n        var emtj_isUpload = 1;\\n        var emtj_pageId = 113200301321;\\n        var emtj_logSet = \"0111111111\";\\n        var emtj_sampleRate = 1;      \\n      </script><script src=\"./static/build/index.js\"></script><script src=\"//emres.dfcfw.com/public/js/topnav1200.js\" async=\"\" defer=\"\"></script><script src=\"//emcharts.dfcfw.com/usercollect/usercollect.min.js\"></script><script src=\"//bdstatics.eastmoney.com/web/prd/jump_tracker.js\"></script><script src=\"//emcharts.dfcfw.com/newsts/newsts.min.js\" async=\"\" defer=\"\"></script>'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "resp.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ac3aef74",
   "metadata": {},
   "outputs": [],
   "source": [
    "soup = BeautifulSoup(resp.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "fe76d824",
   "metadata": {},
   "outputs": [],
   "source": [
    "soup.find('tbody')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e96146c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<!DOCTYPE html>\n",
       "<html><head><meta charset=\"utf-8\"/><meta content=\"IE=edge,chrome=1\" http-equiv=\"X-UA-Compatible\"/><meta content=\"width=device-width, initial-scale=1.0\" name=\"viewport\"/><meta content=\"always\" name=\"referrer\"/><meta data-bz=\"STime: 2025-08-05 21:41:39 SNum: 194\" name=\"sinfo\"/><title>行情中心：国内快捷全面的股票、基金、期货、美股、港股、外汇、黄金、债券行情系统_东方财富网</title><meta content=\"沪深股市, 沪深A股, 沪深指数, 创业板行情, 期指行情, 板块, 排行, 香港股市, 美股行情, 港股行情, 全球指数, 基金净值, 基金估值, ETF, LOF, 基金行情, 期货行情, 外汇, 人民币中间价, 外汇牌价, 汇率, 黄金, 黄金期货, 黄金现货, 纸黄金, 国际贵金属期货, 债券指数, 国债, 企债, 转债, 银行间市场, 上证回购, 深证回购 \" name=\"keywords\"/><meta content=\"东方财富网行情中心提供权威、全面、专业、及时的行情数据，将沪深股市实时行情、港股行情、全球股市走势、权证、基金行情、期货行情、外汇行情、债券行情、黄金行情进行优化整合、为投资者搭建了一个可以纵览全球行情的重要平台，为您的投资提供重要依据。\" name=\"description\"/><base target=\"_blank\"/><link href=\"./static/build/index.css\" rel=\"stylesheet\"/></head><body><div class=\"main\"><div id=\"qq_top_tg\"></div><div class=\"toplinks blink\"><ul><li><a href=\"http://finance.eastmoney.com/\">财经</a></li><li><a href=\"http://finance.eastmoney.com/yaowen.html\">焦点</a></li><li><a href=\"http://stock.eastmoney.com/\">股票</a></li><li><span class=\"red\"><a href=\"http://stock.eastmoney.com/newstock.html\">新股</a></span></li><li><a href=\"http://stock.eastmoney.com/gzqh.html\">期指</a></li><li><a href=\"http://option.eastmoney.com/\">期权</a></li><li><span class=\"red\"><a href=\"http://quote.eastmoney.com/flash/sz300059.html\">行情</a></span></li><li><a href=\"http://data.eastmoney.com/\">数据</a></li><li><a href=\"http://stock.eastmoney.com/global.html\">全球</a></li><li><a href=\"http://stock.eastmoney.com/america.html\">美股</a></li><li><a href=\"http://hk.eastmoney.com/\">港股</a></li><li><a href=\"http://futures.eastmoney.com/\">期货</a></li><li><a href=\"http://forex.eastmoney.com/\">外汇</a></li><li><a href=\"http://bank.eastmoney.com/\">银行</a></li><li><a href=\"http://www.1234567.com.cn/\">基金</a></li><li><a href=\"http://money.eastmoney.com/\">理财</a></li><li><a href=\"http://bond.eastmoney.com/\">债券</a></li><li><a href=\" https://roadshow.eastmoney.com/\">直播</a></li><li><span class=\"red\"><a href=\"http://guba.eastmoney.com/\">股吧</a></span></li><li><a href=\"http://guba.eastmoney.com/jj.html\">基金吧</a></li><li><a href=\"http://blog.eastmoney.com/\">博客</a></li><li><span class=\"red\"><a href=\"http://caifuhao.eastmoney.com/\">财富号</a></span></li><li><a href=\"http://so.eastmoney.com/\">搜索</a></li></ul></div><div class=\"toptitle scf\"><div class=\"logo\"><a href=\"http://www.eastmoney.com\"><img class=\"logoimg\" src=\"./static/images/logo.png\" title=\"东方财富网\"/></a><a href=\"./\"><span class=\"title\">行情中心</span></a></div><div class=\"tglinks\"><ul><li><a href=\"//kuaixun.eastmoney.com/\"><span class=\"icon_globe\"></span>全球财经快讯</a></li><li><a href=\"//data.eastmoney.com/\"><span class=\"icon_chart\"></span>数据中心</a></li><li><a href=\"//wap.eastmoney.com/\"><span class=\"icon_mobile\"></span>手机站</a></li><li><a href=\"//acttg.eastmoney.com/pub/pctg_hskh_act_gfcgrj_01_01_01_0\"><span class=\"icon_mobile2\"></span>客户端</a></li><li><a href=\"https://choice.eastmoney.com?adid=web_choice_hqpd_website_01_01_01_0\"><span class=\"icon_choice\"></span>Choice数据</a></li><li><a href=\"https://ai.eastmoney.com/miaoxiang/?adid=web_mx_hqzx_website_01_01_01_0\"><span class=\"icon_mx\"></span>妙想大模型</a></li><li><a href=\"//fundact.eastmoney.com/app/?spm=100003.mjj\"><span class=\"icon_download\"></span>手机买基金 国内外市场轻松投</a></li></ul></div></div><div class=\"topsearch scf\"><ul class=\"topsearch_l blink\"><li><a href=\"./\" target=\"_blank\" title=\"行情数据\">行情数据</a></li><li><a href=\"https://jywg.18.cn/Trade/Buy\" target=\"_blank\"><span class=\"icon_zq\"></span>证券交易</a></li><li><a href=\"http://www.1234567.com.cn/\" target=\"_blank\"><span class=\"icon_jj\"></span>基金理财</a></li><li><a href=\"http://group.eastmoney.com/\" target=\"_blank\"><span class=\"icon_zh\"></span>投资组合</a></li><li><a href=\"http://guba.eastmoney.com/\" target=\"_blank\"><span class=\"icon_gb\"></span>股吧互动</a></li></ul><div class=\"topsearch_s\"><form id=\"suggest_wrapper\"><input class=\"topnav2seinp\" id=\"search_box\" name=\"search-suggest\" type=\"text\"/><input class=\"topnav2sebtn\" id=\"search_btn\" type=\"submit\" value=\"搜索\"/></form></div></div><div class=\"topquote\"><div class=\"topquote_i topquote_i_b\"><div class=\"topquote_l\"><a href=\"https://quote.eastmoney.com/\"><span class=\"icon_quote\"></span>行情中心</a></div><div class=\"topquote_r\"><div class=\"topquote_tglinks\"><ul><li><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_01_0\">指数</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_02_0\">期指</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_03_0\">期权</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_04_0\">个股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_05_0\">板块</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_06_0\">行业</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_07_0\">概念</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_08_0\">排行</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_09_0\">新股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_10_0\">北交所</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_11_0\">创业板</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_12_0\">科创板</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_14_0\">基金</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_13_0\">港股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_15_0\">沪深港</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_16_0\">美股</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_17_0\">期货</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_18_0\">黄金</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_19_0\">外汇</a><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_20_0\">自选股</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_02_01_21_0\">自选基金</a><a href=\"https://xuangu.eastmoney.com/\">条件选股</a><span class=\"red\"><a href=\"https://quote.eastmoney.com/stockhotmap/\">大盘星图</a></span></li></ul></div></div></div><div class=\"topquote_i\"><div class=\"topquote_l blink\"><a href=\"qqzs.html\"><span class=\"icon_globe2\"></span>全球股市</a></div><div class=\"topquote_r\"><div class=\"globalstocks\" id=\"globalstocks\"></div><div class=\"topquote_rtg\"><a class=\"cft-dl redlink\" href=\"http://acttg.eastmoney.com/pub/web_pc_dcsy_qqgs_01_01_01_1\" target=\"_blank\"><span class=\"icon_em\"></span>东方财富官方炒股软件</a><a class=\"qdhq-dl redlink\" href=\"http://acttg.eastmoney.com/pub/web_pc_dcsy_qqgs_01_01_02_1\" target=\"_blank\"><span class=\"icon_flash\"></span>快速行情</a></div></div></div><div class=\"topquote_i\"><div class=\"topquote_l blink\"><a href=\"http://data.eastmoney.com/\"><span class=\"icon_chart2\"></span>数据中心</a></div><div class=\"topquote_r\"><div class=\"topquote_tglinks2\"><ul><li><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_01_0\">资金流向</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_02_0\">主力排名</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_03_0\">板块资金</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_04_0\">个股研报</a><span class=\"red\"><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_05_0\">新股申购</a></span><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_06_0\">转债申购</a><span class=\"red\"><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_07_0\">北交所申购</a></span><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_08_0\">AH股比价</a><a href=\"https://data.eastmoney.com/bbsj/202412/yjbb.html\">年报大全</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_10_0\">融资融券</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_11_0\">龙虎榜</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_12_0\">限售解禁</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_13_0\">IPO审核</a><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_14_0\">大宗交易</a><span class=\"red\"><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_dhl_03_01_15_0\">估值分析</a></span></li></ul></div></div></div><div class=\"topquote_i\"><div class=\"topquote_l blink\"><a href=\"hsgt.html\"><span class=\"icon_change\"></span>沪深港通</a></div><div class=\"topquote_r\"><div class=\"tq_hsgt\" id=\"tq_hsgt\"></div></div></div></div><div class=\"bhistory scf\"><div class=\"bs_l\">最近访问：</div><div id=\"bhistory\"></div><div class=\"bs_toutiao\"><div class=\"t\"><a href=\"//js1.eastmoney.com/tg.aspx?ID=3979\"><span class=\"icon_toutiao\"></span>头条</a>：</div><div class=\"list red\"><a href=\"//js1.eastmoney.com/tg.aspx?ID=3979\">金融支持新型工业化最新部署</a></div></div><div id=\"zhrool\"></div></div><div class=\"mainlc scf\" id=\"mainpage\"></div><div class=\"statement\">郑重声明：本网站所刊载的所有资料及图表仅供参考使用。投资者依据本网站提供的信息、资料及图表进行金融、证券等投资所造成的盈亏与本网站无关。本网站如因系统维护或升级而需暂停服务，或因线路及超出本公司控制范围的硬件故障或其它不可抗力而导致暂停服务，于暂停服务期间造成的一切不便与损失，本网站不负任何责任。</div></div><div class=\"footer page_footer\"><!-- footer-2016 -->\n",
       "<style>\n",
       "    .footer2016 ul {list-style: none;margin: 0;padding: 0;}\n",
       "    .footer2016 a:hover{color:#ff4901 !important;text-decoration: underline !important;}\n",
       "    .footer2016 .icon, .footer2016 .navlist li a {display: inline-block;}\n",
       "    .footer2016 .icon {background-image: url(//g1.dfcfw.com/g4/202005/20200513165332.png);background-repeat: no-repeat;}\n",
       "    .footer2016 {margin: 0 auto;clear: both;width: 1200px;line-height: 1.1;_line-height: 1.2;font-family: simsun;font-size: 12px;border-top: 2px solid #2F5895;}\n",
       "    .footer2016 .footertg {background-color: #F3F3F3;float: left;width: 100%;padding: 12px 0 0;height: 140px;}\n",
       "    .footer2016 .footertg a:link, .footer2016 .footertg a:visited {color: #676767;text-decoration: none;}\n",
       "    .footer2016 .qr {float: left;width: 80px;height: 140px;line-height: 150%;padding: 0 20px 0 8px;}\n",
       "    .footer2016 .qr .t {font-weight: 700;font-size: 14px;padding-bottom: 10px;}\n",
       "    .footer2016 .icon_qrem80, .footer2016 .icon_qrjj80 {background-image: url(//g1.dfcfw.com/g2/201607/20160728133707.png);width: 80px;height: 80px;}\n",
       "    .footer2016 .icon_qrem80 {background-position: 0 -330px;}\n",
       "    .footer2016 .icon_emwxqr, .footer2016 .icon_jjwxqr {background-image: url(//g1.dfcfw.com/g2/201607/20160728133707.png);width: 86px;height: 106px;}\n",
       "    .footer2016 .icon_emwxqr {background-position: -90px 0;}\n",
       "    .footer2016 .ftglist ul li.qrli {position: relative;}\n",
       "    .footer2016 .ftglist ul li.qrli:hover .icon_qr, .footer2016 .scl-news .name a {display: block;}\n",
       "    .footer2016 .icon_emwxqr, .footer2016 .icon_jjwxqr {display: none;position: absolute;left: 0;top: 24px;}\n",
       "    .footer2016 .ftglist {float: left;height: 140px;padding: 0 20px;}\n",
       "    .footer2016 .ftglistt {font-size: 14px;font-weight: 700;line-height: 130%;padding-bottom: 6px;text-align: left;}\n",
       "    .footer2016 .ftglist ul li {padding: 5px 0;color: #676767;text-align: left;}\n",
       "    .footer2016 .icon_wb {background-position: -24px 0;width: 14px;height: 12px;}\n",
       "    .footer2016 .icon_wx {background-position: 0 0;width: 14px;height: 11px;}\n",
       "    .footer2016 .icon_note {background-position: -47px 0;width: 13px;height: 11px;}\n",
       "    .footer2016 .ftglist .icon {vertical-align: -1px;margin-right: 2px;}\n",
       "    .footer2016 .footertg a:link, .footer2016 .footertg a:visited {color: #676767;text-decoration: none;}\n",
       "    .footer2016 .qrl {border-left: 1px solid #ddd;margin-left: 20px;padding-left: 40px;}\n",
       "    .footer2016 .icon_qrjj80 {background-position: -90px -330px;}\n",
       "    .footer2016 .footercr {clear: both;text-align: center;line-height: 26px;font-size: 12px;width:1200px;margin: 0 auto;height:26px;overflow:hidden;}\n",
       "    .footer2016 .icon_icp {background-position: -24px -21px;width: 15px;height: 17px;}\n",
       "    .footer2016 .footercr .icon {vertical-align: -3px;margin-right: 2px;}\n",
       "    .footer2016 .icon_pol {background-position: 0 -22px;width: 18px;height: 20px;}\n",
       "    .footer2016 .footerlinks {background-color: #2F5895;height: 30px;text-align: center;line-height: 30px;}\n",
       "    .footer2016 .footerlinks a:link, .footer2016 .footerlinks a:visited, .footer2016 .footerlinks a:hover {color: #fff !important;text-decoration: none;margin: 0 14px;}\n",
       "    .footer2016 .footerbz {text-align: center;padding: 12px 0;}\n",
       "    .footer2016 .footerbz a {margin: 0 4px;}\n",
       "    .footer2016 .footer-police {background-position: 0 -112px;width: 110px;height: 40px;}\n",
       "    .footer2016 .footer-zx110 {background-position: -120px -113px;width: 110px;height: 40px;}\n",
       "    .footer2016 .footer-shjubao {background-position: 0 -172px;width: 110px;height: 40px;}\n",
       "    .footer2016 .footer-cxzx {background-position: -120px -174px;width: 40px;height: 40px;}\n",
       "    .footer2016 .footer-shgs {background-position: -180px -174px;width: 47px;height: 40px;}\n",
       "    .footer2016 .footer-12377 {background-position: 0 -54px;width: 186px;height: 40px;}\n",
       "    .footer2016 .footer-yhjb {background-position: 0 -229px;width: 123px;height: 40px;}\n",
       "    .footer2016 .footer-qrlast {width: 90px;}\n",
       "    .footer2016 .footer-icon-qihuoqr { background: url(https://g1.dfcfw.com/g4/202303/20230324150231.png);width: 80px;height: 80px;display: inline-block;background-repeat: no-repeat;vertical-align: -5px;}\n",
       "    .footer2016 .footer-lastqihuo { padding-right: 0px;}\n",
       "</style>\n",
       "<div class=\"footer2016\">\n",
       "<div class=\"footertg\">\n",
       "<div class=\"qr\">\n",
       "<div class=\"t\"><a href=\"http://acttg.eastmoney.com/pub/web_dfcfsy_dbtg_wzl_01_01_01_1\" style=\"color:#000\" target=\"_blank\">东方财富</a></div>\n",
       "<a href=\"http://acttg.eastmoney.com/pub/web_app_dcsy_2wm_01_01_01_0\" target=\"_blank\"><em class=\"icon icon_qrem80\"></em></a><br/>扫一扫下载APP\n",
       "        </div>\n",
       "<div class=\"ftglist\">\n",
       "<div class=\"ftglistt\">东方财富产品</div>\n",
       "<ul>\n",
       "<li><a href=\"https://acttg.eastmoney.com/pub/pctg_hskh_act_dfcfwmfb_01_01_01_0\" target=\"_blank\">东方财富免费版</a></li>\n",
       "<li><a href=\"https://acttg.eastmoney.com/pub/pctg_hskh_act_dfcfwl2_01_01_01_0\" target=\"_blank\">东方财富Level-2</a></li>\n",
       "<li><a href=\"https://www.dfcfw.com/CLB/\" target=\"_blank\">东方财富策略版</a></li>\n",
       "<li><a href=\"https://acttg.eastmoney.com/pub/web_dfcfsy_wzl_bottom_02_02_04_1\" target=\"_blank\">妙想投研助理</a></li>\n",
       "<li><a href=\"https://choice.eastmoney.com/terminal?adid=web_choice_dcsy_website_02_01_01_0\" target=\"_blank\">Choice金融终端</a></li>\n",
       "</ul>\n",
       "</div>\n",
       "<div class=\"ftglist\">\n",
       "<div class=\"ftglistt\">证券交易</div>\n",
       "<ul>\n",
       "<li><a href=\"https://acttg.eastmoney.com/pub/web_kh_dcsy_dbtkwzl_01_01_01_0\" target=\"_blank\">东方财富证券开户</a></li>\n",
       "<li><a href=\"https://jywg.18.cn/Trade/Buy\" target=\"_blank\">东方财富在线交易</a></li>\n",
       "<li><a href=\"https://acttg.eastmoney.com/pub/pctg_hskh_act_dfcfzqjy_01_01_01_0\" target=\"_blank\">东方财富证券交易</a></li>\n",
       "</ul>\n",
       "</div>\n",
       "<div class=\"ftglist\">\n",
       "<div class=\"ftglistt\">关注东方财富</div>\n",
       "<ul>\n",
       "<li><a href=\"http://weibo.com/dfcfw\" target=\"_blank\"><em class=\"icon icon_wb\"></em>东方财富网微博</a></li>\n",
       "<li class=\"qrli\"><a href=\"javascript:;\" target=\"_self\"><em class=\"icon icon_wx\"></em>东方财富网微信</a><em class=\"icon icon_qr icon_emwxqr\"></em></li>\n",
       "<li><a href=\"http://corp.eastmoney.com/Lianxi_liuyan.asp\" target=\"_blank\"><em class=\"icon icon_note\"></em>意见与建议</a></li>\n",
       "</ul>\n",
       "</div>\n",
       "<div class=\"qr qrl\">\n",
       "<div class=\"t\"><a href=\"http://acttg.eastmoney.com/pub/web_ttjjsy_dbtg_wzl_01_01_01_1\" style=\"color:#000\" target=\"_blank\">天天基金</a></div>\n",
       "<a href=\"http://js1.eastmoney.com/tg.aspx?ID=4672\" target=\"_blank\"><em class=\"icon icon_qrjj80\"></em></a><br/>扫一扫下载APP\n",
       "        </div>\n",
       "<div class=\"ftglist\">\n",
       "<div class=\"ftglistt\">基金交易</div>\n",
       "<ul>\n",
       "<li><a href=\"https://trade6.1234567.com.cn/reg/step1\" target=\"_blank\">基金开户</a></li>\n",
       "<li><a href=\"https://trade.1234567.com.cn/login\" target=\"_blank\">基金交易</a></li>\n",
       "<li><a href=\"http://huoqibao.1234567.com.cn/\" target=\"_blank\">活期宝</a></li>\n",
       "<li><a href=\"http://fund.eastmoney.com/trade/default.html\" target=\"_blank\">基金产品</a></li>\n",
       "<li><a href=\"http://fund.eastmoney.com/gslc/\" target=\"_blank\">稳健理财</a></li>\n",
       "</ul>\n",
       "</div>\n",
       "<div class=\"ftglist\">\n",
       "<div class=\"ftglistt\">关注天天基金</div>\n",
       "<ul>\n",
       "<li><a href=\"http://weibo.com/ttfund\" target=\"_blank\"><em class=\"icon icon_wb\"></em>天天基金网微博</a></li>\n",
       "<li class=\"qrli\"><a href=\"javascript:;\" target=\"_self\"><em class=\"icon icon_wx\"></em>天天基金网微信<em class=\"icon icon_qr icon_jjwxqr\"></em></a></li>\n",
       "</ul>\n",
       "</div>\n",
       "<div class=\"qr qrl footer-qrlast\">\n",
       "<div class=\"t\"><a href=\"https://qs.dfcfw.com/1605\" style=\"color:#000\" target=\"_blank\">东方财富期货</a></div>\n",
       "<a href=\"http://acttg.eastmoney.com/pub/web_kh_dcsy_dibudfcfqh_01_01_01_1\" target=\"_blank\"><em class=\"footer-icon-qihuoqr\"></em></a><br/>扫一扫下载APP\n",
       "        </div>\n",
       "<div class=\"ftglist footer-lastqihuo\">\n",
       "<div class=\"ftglistt\">期货交易</div>\n",
       "<ul>\n",
       "<li><a href=\"https://qs.dfcfw.com/1606\" target=\"_blank\">期货手机开户</a></li>\n",
       "<li><a href=\"https://qs.dfcfw.com/1607\" target=\"_blank\">期货电脑开户</a></li>\n",
       "<li><a href=\"https://qs.dfcfw.com/1608\" target=\"_blank\">期货官方网站</a></li>\n",
       "</ul>\n",
       "</div>\n",
       "</div>\n",
       "<div class=\"footercr\" style=\"padding-top:8px;\">信息网络传播视听节目许可证：0908328号 经营证券期货业务许可证编号：913101046312860336 违法和不良信息举报:021-61278686 举报邮箱：<a href=\"mailto:jubao@eastmoney.com\" target=\"_self\">jubao@eastmoney.com</a></div>\n",
       "<div class=\"footercr\" style=\"padding-bottom:8px;\">\n",
       "<em class=\"icon icon_icp\"></em>沪ICP证:沪B2-20070217 <a href=\"https://beian.miit.gov.cn/\" rel=\"nofollow\" style=\"color: #3F3F3F;text-decoration:none;\" target=\"_blank\">网站备案号:沪ICP备05006054号-11 </a> <a href=\"http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31010402000120\" rel=\"nofollow\" style=\"color: #3F3F3F;text-decoration:none;\" target=\"_blank\"><em class=\"icon icon_pol\"></em>沪公网安备 31010402000120号</a> 版权所有:东方财富网 <span class=\"yjyfk\">意见与建议:4000300059/952500</span>\n",
       "</div>\n",
       "<div class=\"footerlinks\">\n",
       "<a href=\"http://about.eastmoney.com\" rel=\"nofollow\" target=\"_blank\">关于我们</a>\n",
       "<a href=\"https://about.eastmoney.com/about/sdindex\" rel=\"nofollow\" target=\"_blank\">可持续发展</a>\n",
       "<a href=\"http://emhd2.eastmoney.com/market\" rel=\"nofollow\" target=\"_blank\">广告服务</a>\n",
       "<a href=\"http://about.eastmoney.com/home/contact\" rel=\"nofollow\" target=\"_blank\">联系我们</a>\n",
       "<a href=\"https://zhaopin.eastmoney.com/\" rel=\"nofollow\" target=\"_blank\">诚聘英才</a>\n",
       "<a href=\"http://about.eastmoney.com/home/legal\" rel=\"nofollow\" target=\"_blank\">法律声明</a>\n",
       "<a href=\"http://about.eastmoney.com/home/conceal\" rel=\"nofollow\" target=\"_blank\">隐私保护</a>\n",
       "<a href=\"http://about.eastmoney.com/home/parper\" rel=\"nofollow\" target=\"_blank\">征稿启事</a>\n",
       "<a href=\"http://about.eastmoney.com/home/links\" rel=\"nofollow\" target=\"_blank\">友情链接</a>\n",
       "</div>\n",
       "<div class=\"footerbz\">\n",
       "<img src=\"//g1.dfcfw.com/g3/201905/20190531140719.png\" style=\"vertical-align: bottom;\" title=\"亲爱的市民朋友，上海警方反诈劝阻电\n",
       "话“962110”系专门针对避免您财产被\n",
       "骗受损而设，请您一旦收到来电，立即\n",
       "接听。\"/>\n",
       "<span class=\"icon footer-police\" style=\"position: relative; margin: 0 4px;\" title=\"上海网警网络110\"></span>\n",
       "<span class=\"icon footer-zx110\" style=\"position: relative;margin: 0 4px;\" title=\"网络社会征信网\"></span>\n",
       "<a class=\"icon footer-shjubao\" href=\"http://www.shjbzx.cn/\" rel=\"nofollow\" target=\"_blank\" title=\"上海违法和违规信息举报中心\"></a>\n",
       "<a class=\"icon footer-12377\" href=\"http://www.12377.cn\" rel=\"nofollow\" target=\"_blank\" title=\"中国互联网违法和不良信息举报中心\"></a>\n",
       "</div>\n",
       "</div>\n",
       "<script>\n",
       "    if(document.all && !window.XMLHttpRequest){\n",
       "        $(\".qrli\").hover(function(){\n",
       "            $(\".icon_qr\",this).show();\n",
       "        },function(){\n",
       "            $(\".icon_qr\",this).hide();\n",
       "        });\n",
       "    }\n",
       "</script></div></body></html>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "soup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "455a939e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "总共发现 5736 条记录，共 287 页。\n",
      "正在爬取第 1/287 页...\n",
      "正在爬取第 2/287 页...\n",
      "正在爬取第 3/287 页...\n",
      "正在爬取第 4/287 页...\n",
      "正在爬取第 5/287 页...\n",
      "正在爬取第 6/287 页...\n",
      "正在爬取第 7/287 页...\n",
      "正在爬取第 8/287 页...\n",
      "正在爬取第 9/287 页...\n",
      "正在爬取第 10/287 页...\n",
      "正在爬取第 11/287 页...\n",
      "正在爬取第 12/287 页...\n",
      "正在爬取第 13/287 页...\n",
      "正在爬取第 14/287 页...\n",
      "正在爬取第 15/287 页...\n",
      "正在爬取第 16/287 页...\n",
      "正在爬取第 17/287 页...\n",
      "正在爬取第 18/287 页...\n",
      "正在爬取第 19/287 页...\n",
      "正在爬取第 20/287 页...\n",
      "正在爬取第 21/287 页...\n",
      "正在爬取第 22/287 页...\n",
      "正在爬取第 23/287 页...\n",
      "正在爬取第 24/287 页...\n",
      "正在爬取第 25/287 页...\n",
      "正在爬取第 26/287 页...\n",
      "正在爬取第 27/287 页...\n",
      "正在爬取第 28/287 页...\n",
      "正在爬取第 29/287 页...\n",
      "正在爬取第 30/287 页...\n",
      "正在爬取第 31/287 页...\n",
      "正在爬取第 32/287 页...\n",
      "正在爬取第 33/287 页...\n",
      "正在爬取第 34/287 页...\n",
      "正在爬取第 35/287 页...\n",
      "正在爬取第 36/287 页...\n",
      "正在爬取第 37/287 页...\n",
      "正在爬取第 38/287 页...\n",
      "正在爬取第 39/287 页...\n",
      "正在爬取第 40/287 页...\n",
      "正在爬取第 41/287 页...\n",
      "正在爬取第 42/287 页...\n",
      "正在爬取第 43/287 页...\n",
      "正在爬取第 44/287 页...\n",
      "正在爬取第 45/287 页...\n",
      "正在爬取第 46/287 页...\n",
      "正在爬取第 47/287 页...\n",
      "正在爬取第 48/287 页...\n",
      "正在爬取第 49/287 页...\n",
      "正在爬取第 50/287 页...\n",
      "正在爬取第 51/287 页...\n",
      "正在爬取第 52/287 页...\n",
      "正在爬取第 53/287 页...\n",
      "正在爬取第 54/287 页...\n",
      "正在爬取第 55/287 页...\n",
      "正在爬取第 56/287 页...\n",
      "正在爬取第 57/287 页...\n",
      "正在爬取第 58/287 页...\n",
      "正在爬取第 59/287 页...\n",
      "正在爬取第 60/287 页...\n",
      "正在爬取第 61/287 页...\n",
      "正在爬取第 62/287 页...\n",
      "正在爬取第 63/287 页...\n",
      "正在爬取第 64/287 页...\n",
      "正在爬取第 65/287 页...\n",
      "正在爬取第 66/287 页...\n",
      "正在爬取第 67/287 页...\n",
      "正在爬取第 68/287 页...\n",
      "正在爬取第 69/287 页...\n",
      "正在爬取第 70/287 页...\n",
      "正在爬取第 71/287 页...\n",
      "正在爬取第 72/287 页...\n",
      "正在爬取第 73/287 页...\n",
      "正在爬取第 74/287 页...\n",
      "正在爬取第 75/287 页...\n",
      "正在爬取第 76/287 页...\n",
      "正在爬取第 77/287 页...\n",
      "正在爬取第 78/287 页...\n",
      "正在爬取第 79/287 页...\n",
      "正在爬取第 80/287 页...\n",
      "正在爬取第 81/287 页...\n",
      "正在爬取第 82/287 页...\n",
      "正在爬取第 83/287 页...\n",
      "正在爬取第 84/287 页...\n",
      "正在爬取第 85/287 页...\n",
      "正在爬取第 86/287 页...\n",
      "正在爬取第 87/287 页...\n",
      "正在爬取第 88/287 页...\n",
      "正在爬取第 89/287 页...\n",
      "正在爬取第 90/287 页...\n",
      "正在爬取第 91/287 页...\n",
      "正在爬取第 92/287 页...\n",
      "正在爬取第 93/287 页...\n",
      "正在爬取第 94/287 页...\n",
      "正在爬取第 95/287 页...\n",
      "正在爬取第 96/287 页...\n",
      "正在爬取第 97/287 页...\n",
      "正在爬取第 98/287 页...\n",
      "正在爬取第 99/287 页...\n",
      "正在爬取第 100/287 页...\n",
      "正在爬取第 101/287 页...\n",
      "正在爬取第 102/287 页...\n",
      "正在爬取第 103/287 页...\n",
      "正在爬取第 104/287 页...\n",
      "正在爬取第 105/287 页...\n",
      "正在爬取第 106/287 页...\n",
      "正在爬取第 107/287 页...\n",
      "正在爬取第 108/287 页...\n",
      "正在爬取第 109/287 页...\n",
      "正在爬取第 110/287 页...\n",
      "正在爬取第 111/287 页...\n",
      "正在爬取第 112/287 页...\n",
      "正在爬取第 113/287 页...\n",
      "正在爬取第 114/287 页...\n",
      "正在爬取第 115/287 页...\n",
      "正在爬取第 116/287 页...\n",
      "正在爬取第 117/287 页...\n",
      "正在爬取第 118/287 页...\n",
      "正在爬取第 119/287 页...\n",
      "正在爬取第 120/287 页...\n",
      "正在爬取第 121/287 页...\n",
      "正在爬取第 122/287 页...\n",
      "正在爬取第 123/287 页...\n",
      "正在爬取第 124/287 页...\n",
      "正在爬取第 125/287 页...\n",
      "正在爬取第 126/287 页...\n",
      "正在爬取第 127/287 页...\n",
      "正在爬取第 128/287 页...\n",
      "正在爬取第 129/287 页...\n",
      "正在爬取第 130/287 页...\n",
      "正在爬取第 131/287 页...\n",
      "正在爬取第 132/287 页...\n",
      "正在爬取第 133/287 页...\n",
      "正在爬取第 134/287 页...\n",
      "正在爬取第 135/287 页...\n",
      "正在爬取第 136/287 页...\n",
      "正在爬取第 137/287 页...\n",
      "正在爬取第 138/287 页...\n",
      "正在爬取第 139/287 页...\n",
      "正在爬取第 140/287 页...\n",
      "正在爬取第 141/287 页...\n",
      "正在爬取第 142/287 页...\n",
      "正在爬取第 143/287 页...\n",
      "正在爬取第 144/287 页...\n",
      "正在爬取第 145/287 页...\n",
      "正在爬取第 146/287 页...\n",
      "正在爬取第 147/287 页...\n",
      "正在爬取第 148/287 页...\n",
      "正在爬取第 149/287 页...\n",
      "正在爬取第 150/287 页...\n",
      "正在爬取第 151/287 页...\n",
      "正在爬取第 152/287 页...\n",
      "正在爬取第 153/287 页...\n",
      "正在爬取第 154/287 页...\n",
      "正在爬取第 155/287 页...\n",
      "正在爬取第 156/287 页...\n",
      "正在爬取第 157/287 页...\n",
      "正在爬取第 158/287 页...\n",
      "正在爬取第 159/287 页...\n",
      "正在爬取第 160/287 页...\n",
      "正在爬取第 161/287 页...\n",
      "正在爬取第 162/287 页...\n",
      "正在爬取第 163/287 页...\n",
      "正在爬取第 164/287 页...\n",
      "正在爬取第 165/287 页...\n",
      "正在爬取第 166/287 页...\n",
      "正在爬取第 167/287 页...\n",
      "正在爬取第 168/287 页...\n",
      "正在爬取第 169/287 页...\n",
      "正在爬取第 170/287 页...\n",
      "正在爬取第 171/287 页...\n",
      "正在爬取第 172/287 页...\n",
      "正在爬取第 173/287 页...\n",
      "正在爬取第 174/287 页...\n",
      "正在爬取第 175/287 页...\n",
      "正在爬取第 176/287 页...\n",
      "正在爬取第 177/287 页...\n",
      "正在爬取第 178/287 页...\n",
      "正在爬取第 179/287 页...\n",
      "正在爬取第 180/287 页...\n",
      "正在爬取第 181/287 页...\n",
      "正在爬取第 182/287 页...\n",
      "正在爬取第 183/287 页...\n",
      "正在爬取第 184/287 页...\n",
      "正在爬取第 185/287 页...\n",
      "正在爬取第 186/287 页...\n",
      "正在爬取第 187/287 页...\n",
      "正在爬取第 188/287 页...\n",
      "正在爬取第 189/287 页...\n",
      "正在爬取第 190/287 页...\n",
      "正在爬取第 191/287 页...\n",
      "正在爬取第 192/287 页...\n",
      "正在爬取第 193/287 页...\n",
      "正在爬取第 194/287 页...\n",
      "正在爬取第 195/287 页...\n",
      "正在爬取第 196/287 页...\n",
      "正在爬取第 197/287 页...\n",
      "正在爬取第 198/287 页...\n",
      "正在爬取第 199/287 页...\n",
      "正在爬取第 200/287 页...\n",
      "正在爬取第 201/287 页...\n",
      "正在爬取第 202/287 页...\n",
      "正在爬取第 203/287 页...\n",
      "正在爬取第 204/287 页...\n",
      "正在爬取第 205/287 页...\n",
      "正在爬取第 206/287 页...\n",
      "正在爬取第 207/287 页...\n",
      "正在爬取第 208/287 页...\n",
      "正在爬取第 209/287 页...\n",
      "正在爬取第 210/287 页...\n",
      "正在爬取第 211/287 页...\n",
      "正在爬取第 212/287 页...\n",
      "正在爬取第 213/287 页...\n",
      "正在爬取第 214/287 页...\n",
      "正在爬取第 215/287 页...\n",
      "正在爬取第 216/287 页...\n",
      "正在爬取第 217/287 页...\n",
      "正在爬取第 218/287 页...\n",
      "正在爬取第 219/287 页...\n",
      "正在爬取第 220/287 页...\n",
      "正在爬取第 221/287 页...\n",
      "正在爬取第 222/287 页...\n",
      "正在爬取第 223/287 页...\n",
      "正在爬取第 224/287 页...\n",
      "正在爬取第 225/287 页...\n",
      "正在爬取第 226/287 页...\n",
      "正在爬取第 227/287 页...\n",
      "正在爬取第 228/287 页...\n",
      "正在爬取第 229/287 页...\n",
      "正在爬取第 230/287 页...\n",
      "正在爬取第 231/287 页...\n",
      "正在爬取第 232/287 页...\n",
      "正在爬取第 233/287 页...\n",
      "正在爬取第 234/287 页...\n",
      "正在爬取第 235/287 页...\n",
      "正在爬取第 236/287 页...\n",
      "正在爬取第 237/287 页...\n",
      "正在爬取第 238/287 页...\n",
      "正在爬取第 239/287 页...\n",
      "正在爬取第 240/287 页...\n",
      "正在爬取第 241/287 页...\n",
      "正在爬取第 242/287 页...\n",
      "正在爬取第 243/287 页...\n",
      "正在爬取第 244/287 页...\n",
      "正在爬取第 245/287 页...\n",
      "正在爬取第 246/287 页...\n",
      "正在爬取第 247/287 页...\n",
      "正在爬取第 248/287 页...\n",
      "正在爬取第 249/287 页...\n",
      "正在爬取第 250/287 页...\n",
      "正在爬取第 251/287 页...\n",
      "正在爬取第 252/287 页...\n",
      "正在爬取第 253/287 页...\n",
      "正在爬取第 254/287 页...\n",
      "正在爬取第 255/287 页...\n",
      "正在爬取第 256/287 页...\n",
      "正在爬取第 257/287 页...\n",
      "正在爬取第 258/287 页...\n",
      "正在爬取第 259/287 页...\n",
      "正在爬取第 260/287 页...\n",
      "正在爬取第 261/287 页...\n",
      "正在爬取第 262/287 页...\n",
      "正在爬取第 263/287 页...\n",
      "正在爬取第 264/287 页...\n",
      "正在爬取第 265/287 页...\n",
      "正在爬取第 266/287 页...\n",
      "正在爬取第 267/287 页...\n",
      "正在爬取第 268/287 页...\n",
      "正在爬取第 269/287 页...\n",
      "正在爬取第 270/287 页...\n",
      "正在爬取第 271/287 页...\n",
      "正在爬取第 272/287 页...\n",
      "正在爬取第 273/287 页...\n",
      "正在爬取第 274/287 页...\n",
      "正在爬取第 275/287 页...\n",
      "正在爬取第 276/287 页...\n",
      "正在爬取第 277/287 页...\n",
      "正在爬取第 278/287 页...\n",
      "正在爬取第 279/287 页...\n",
      "正在爬取第 280/287 页...\n",
      "正在爬取第 281/287 页...\n",
      "正在爬取第 282/287 页...\n",
      "正在爬取第 283/287 页...\n",
      "正在爬取第 284/287 页...\n",
      "正在爬取第 285/287 页...\n",
      "正在爬取第 286/287 页...\n",
      "正在爬取第 287/287 页...\n",
      "     股票代码  股票名称    最新价   涨跌幅     昨收    今开    最高    最低            成交额      成交量\n",
      "0  300486  东杰智能   2039  2001   2039  1869  1905  1699  2642802446.72  1334176\n",
      "1  688585  上纬新材  11048  2000  11048  8973  9600  9207   2318898288.0   231546\n",
      "2  300916  朗特智能   4273  1999   4273  3562  3600  3561   898870098.97   218317\n",
      "3  301076  新瀚新材   3715  1999   3715  3138  3146  3096  1338084589.15   382722\n",
      "4  300689  澄天伟业   5672  1999   5672  4620  4780  4727    418049250.1    81879\n",
      "所有数据已成功保存到 eastmoney_all_stocks.csv\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "import json\n",
    "import re\n",
    "import pandas as pd\n",
    "import math\n",
    "import time\n",
    "\n",
    "# 基础 URL 和通用参数\n",
    "base_url = 'https://push2.eastmoney.com/api/qt/clist/get'\n",
    "headers = {\n",
    "    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',\n",
    "}\n",
    "\n",
    "# 你提供的完整请求参数，这里需要将它们解构为字典\n",
    "# 注意：你需要将这些参数完整地填入，以确保请求成功\n",
    "params = {\n",
    "    'np': '1',\n",
    "    'fltt': '1',\n",
    "    'invt': '2',\n",
    "    'cb': 'jQuery37104650810082413308_1754403364628', # 这个回调函数名每次可能不同，不影响请求\n",
    "    'fs': 'm:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23,m:0+t:81+s:2048',\n",
    "    'fields': 'f12,f13,f14,f1,f2,f4,f3,f152,f5,f6,f7,f15,f18,f16,f17,f10,f8,f9,f23',\n",
    "    'fid': 'f3',\n",
    "    'pn': '1',  # 初始页码\n",
    "    'pz': '20', # 初始每页条数\n",
    "    'po': '1',\n",
    "    'dect': '1',\n",
    "    'ut': 'fa5fd1943c7b386f172d6893dbfba10b',\n",
    "    'wbp2u': '|0|0|0|web',\n",
    "    '_': str(int(time.time() * 1000)) # 时间戳参数，可以动态生成\n",
    "}\n",
    "\n",
    "all_stocks_data = []\n",
    "\n",
    "try:\n",
    "    # 1. 获取第一页数据，以确定总页数\n",
    "    response = requests.get(base_url, headers=headers, params=params)\n",
    "    response.raise_for_status()\n",
    "\n",
    "    # 使用正则表达式提取 JSONP 中的 JSON 数据\n",
    "    jsonp_text = response.text\n",
    "    json_match = re.search(r'\\((.*)\\)', jsonp_text, re.S)\n",
    "\n",
    "    if json_match:\n",
    "        json_data = json_match.group(1)\n",
    "        data = json.loads(json_data)\n",
    "        \n",
    "        total_records = data['data']['total']\n",
    "        page_size = int(params['pz'])\n",
    "        total_pages = math.ceil(total_records / page_size)\n",
    "\n",
    "        print(f\"总共发现 {total_records} 条记录，共 {total_pages} 页。\")\n",
    "\n",
    "        # 2. 循环遍历所有页码，获取所有数据\n",
    "        for page_num in range(1, total_pages + 1):\n",
    "            print(f\"正在爬取第 {page_num}/{total_pages} 页...\")\n",
    "            \n",
    "            # 更新请求参数中的页码\n",
    "            params['pn'] = str(page_num)\n",
    "            \n",
    "            # 发送请求\n",
    "            page_response = requests.get(base_url, headers=headers, params=params)\n",
    "            page_response.raise_for_status()\n",
    "            \n",
    "            # 解析 JSONP\n",
    "            page_jsonp_text = page_response.text\n",
    "            page_json_match = re.search(r'\\((.*)\\)', page_jsonp_text, re.S)\n",
    "\n",
    "            if page_json_match:\n",
    "                page_json_data = page_json_match.group(1)\n",
    "                page_data = json.loads(page_json_data)\n",
    "                \n",
    "                # 将本页数据添加到总列表中\n",
    "                all_stocks_data.extend(page_data['data']['diff'])\n",
    "            \n",
    "            # 为了避免请求过于频繁，建议每次爬取后暂停一下\n",
    "            time.sleep(1)\n",
    "\n",
    "        # 3. 数据清洗和保存\n",
    "        # 定义一个字典，映射字段名到可读的中文名\n",
    "        field_map = {\n",
    "            'f2': '最新价',\n",
    "            'f3': '涨跌幅',\n",
    "            'f4': '涨跌额',\n",
    "            'f5': '成交量',\n",
    "            'f6': '成交额',\n",
    "            'f7': '振幅',\n",
    "            'f8': '换手率',\n",
    "            'f9': '市盈率',\n",
    "            'f10': '量比',\n",
    "            'f12': '股票代码',\n",
    "            'f14': '股票名称',\n",
    "            'f15': '最高',\n",
    "            'f16': '最低',\n",
    "            'f17': '今开',\n",
    "            'f18': '昨收',\n",
    "            'f23': '市净率'\n",
    "        }\n",
    "\n",
    "        clean_stocks = []\n",
    "        for stock in all_stocks_data:\n",
    "            clean_stock = {}\n",
    "            for key, value in field_map.items():\n",
    "                if key in stock:\n",
    "                    # 某些数值字段需要进行单位转换\n",
    "                    # 注意：这里需要根据你找到的实际数据进行调整\n",
    "                    clean_stock[value] = stock[key]\n",
    "            clean_stocks.append(clean_stock)\n",
    "        \n",
    "        # 创建 Pandas DataFrame 并保存到 CSV\n",
    "        df = pd.DataFrame(clean_stocks)\n",
    "        print(df.head())\n",
    "        df.to_csv('eastmoney_all_stocks.csv', index=False, encoding='utf_8_sig')\n",
    "        print(\"所有数据已成功保存到 eastmoney_all_stocks.csv\")\n",
    "\n",
    "    else:\n",
    "        print(\"未找到 JSONP 数据。请检查 URL 或返回内容是否发生了变化。\")\n",
    "\n",
    "except requests.exceptions.RequestException as e:\n",
    "    print(f\"请求失败: {e}\")\n",
    "except json.JSONDecodeError:\n",
    "    print(\"JSON解析失败，请检查返回数据格式。\")\n",
    "except Exception as e:\n",
    "    print(f\"发生错误: {e}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
